package com.sinoglobal.ningxia.activity.shop;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.sinoglobal.ningxia.R;

/**
 * 
 * @author zbl
 * @createdate 2014-6-27 下午5:11:03
 * @Description:点击“查看”里面现金购买单条信息，进入此页面查看物流详情
 */
@SuppressLint("SetJavaScriptEnabled")
public class CashGoodsLogisticsActivity extends Activity {
	private WebView myWebView = null;
	private Intent intent;
	private String companyInfo;// 物流公司编码
	private String waybillInfo;// 运单号码
	private final  String URL="http://m.kuaidi100.com/index_all.html";
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_cash_goods_logistics);
		
		//获取物流公司编码和运单号码
		intent = getIntent();
		companyInfo = intent.getStringExtra("companyInfo");
		waybillInfo = intent.getStringExtra("waybillInfo");
		// 打开网页
		myWebView = (WebView) findViewById(R.id.webview111);
		myWebView.getSettings().setJavaScriptEnabled(true);// 兼容js样式
															// JavaScript使能(如果要加载的页面中有JS代码，则必须使能JS)
		String newUrl=URL+"?type="+companyInfo+"&postid="+waybillInfo+"#result";
		myWebView.loadUrl(newUrl);
		myWebView.setWebViewClient(new WebViewClient() {
			@Override
			public void onPageFinished(WebView view, String url) {
				// 此方法还得测试其他机型是否兼容，原理每次加载页面，如是顶层页面，return，不是直接finish掉
				if (!myWebView.canGoBack())
					return;
				finish();
				super.onPageFinished(view, url);
			}

		});

	}
}
